<button class="btn btn-success btn-sm" data-toggle="modal" data-target="#taskCreate">新增黑名单</button>

<div class="modal fade" id="taskCreate" tabindex="-1" role="dialog" aria-labelledby="taskCreate"
     aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">&times;</button>
                <h4 class="modal-title" id="myModalLabel">新增黑名单</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">客户名称</label>
                    <input type="text" name="name" class="form-control" placeholder="请输入客户名称">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">年龄</label>
                    <input type="number" name="age" max="99" maxlength="2" class="form-control" placeholder="请输入年龄">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">性别</label>
                    <select class="form-select form-control" name="gender">
                        <option value="0">女</option>
                        <option value="1">男</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">手机号</label>
                    <input type="text" name="mobile" maxlength="11" class="form-control" placeholder="请输入手机号">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">地区</label>
                    <input type="text" name="area" class="form-control" placeholder="请输入地区">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">微信</label>
                    <input type="text" name="wechat" class="form-control" placeholder="请输入微信">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">备注</label>
                    <textarea name="remark" class="form-control" placeholder="请输入备注"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="customerCreate()">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function customerCreate()
    {
        if($("input[name='age']").val() > 99) alert('年龄不能超出99');
        ajaxPostFunc('/admin/ajax/blacklistCreate', {
            name: $("input[name='name']").val(),
            age: $("input[name='age']").val(),
            gender: $("select[name='gender']").val(),
            mobile: $("input[name='mobile']").val(),
            area: $("input[name='area']").val(),
            wechat: $("input[name='wechat']").val(),
            remark: $("input[name='remark']").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
